package com.platform.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;

import java.io.Serializable;
import java.util.Objects;

@Data
public abstract class IdEntity<T extends IdEntity> extends BaseEntity<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id",type = IdType.AUTO)
    private Long id;

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        if(id == null && ((IdEntity)o).id == null){
            return false;
        }
        return Objects.equals(id, ((IdEntity)o).id);
    }
    @Override
    public int hashCode() {
        return Objects.hashCode(id);
    }
}
